## GNU General Public License
## 
## Program pyNastran - a python interface to NASTRAN files
## Copyright (C) 2011  Steven P. Doyle
## 
## Author and copyright holder of pyMastran
## Steven Doyle <mesheb82@gmail.com>
## 
## This file is part of pyNastran.
## 
## pyNastran is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
## 
## pyNastran is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
## 
## You should have received a copy of the GNU General Public License
## along with pyNastran.  If not, see <http://www.gnu.org/licenses/>.
## 
## This header is automatically generated by applyLicense.py and any
## changes to it will be lost.
## 
from numpy import matrix
from types import NoneType

def ListPrint(listA):
    if len(listA)==0:
        return '[]'
    ###

    msg = '['
    if isinstance(listA,matrix):
        (nrows,ncols) = listA.shape
        for irow in range(nrows):
            msg += '['
            for icol in range(ncols):
                msg += '%-10g,' %(listA[irow,icol])
            ###
            msg = msg[:-1]
            msg += '],\n '
        ###
        msg = msg[:-1]
        msg += ']'

    else:
        for a in listA:
            #print "a = ",a,type(a)
            if isinstance(a,str):
                msg += ' %s,' %(a)
            elif isinstance(a,NoneType):
                msg += ' None,'
            elif isinstance(a,float):
                msg += ' %-4.2f,' %(a)
            elif isinstance(a,int):
                msg += ' %g,' %(a)
            else:
                try:
                    msg += ' %g,' %(a)
                except TypeError:
                    print "a = |%s|" %(a)
                    raise
                ###
            ###
        ###
        msg = msg[:-1]
        msg += ' ]'
    ###
    return msg

